------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/kcb38/Library/CloudStorage/Box-Box/Relation creation/JOPreplication/Fi
> gA5_JOPreplication.log
  log type:  text
 opened on:  21 Aug 2023, 15:58:29

. do "/var/folders/_k/kq9jm16n2j56f62vqdthwl3x___x66/T//SD29851.000000"

. clear

. 
. *cd "[Directory Information Here]" 
. cd "/Users/kcb38/Library/CloudStorage/Box-Box/Relation creation/JOPreplication/"
/Users/kcb38/Library/CloudStorage/Box-Box/Relation creation/JOPreplication

. 
. insheet using "relation_nodal.csv", clear
(20 vars, 4,684 obs)

. rename ccode1 ccode

. sort ccode year 

. save relation_nodal_merge, replace
file relation_nodal_merge.dta saved

. insheet using "relation_network.csv", clear
(13 vars, 710,320 obs)

. 
. 
. *Merge in nodal characteristics of state 2
. rename ccode2 ccode

. sort ccode year

. merge m:1 ccode year using relation_nodal_merge, nogen keep(match master)

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                           710,320  
    -----------------------------------------

. rename ccode ccode2

. 
. *Narrow in on cases that received Soviet Support in 1988 and that were threat targets of
>  the US
. gen USSRsupport88=1 if ccode1==365 & year==1988 & support_bin==1
(710,271 missing values generated)

. gen USAsupport88=1 if ccode1==2 & year==1988 & support_bin==1
(710,258 missing values generated)

. sort ccode2 year

. by ccode2: egen USSRsupport2=max(USSRsupport88)
(490,241 missing values generated)

. by ccode2: egen USAsupport2=max(USAsupport88)
(419,912 missing values generated)

. sort ccode1 ccode2 year

. gen USAtarget2=1 if USSRsupport2==1 & threat_bin==1 & ccode1==2
(710,129 missing values generated)

. list ccode2 if ccode1==2 & USAtarget2==1 & year==1988

        +--------+
        | ccode2 |
        |--------|
    71. |     40 |
   350. |     93 |
  2764. |    540 |
  3219. |    620 |
  3343. |    645 |
        |--------|
  3756. |    700 |
  3980. |    731 |
  4321. |    811 |
        +--------+

. *Cuba, Nicaragua, Angola, Libya, Iraq, Afghanistan, North Korea, Cambodia
. list ccode2 if ccode1==2 & USAtarget2==1 & year==1992

        +--------+
        | ccode2 |
        |--------|
    75. |     40 |
  1292. |    345 |
  2768. |    540 |
  3347. |    645 |
  3760. |    700 |
        |--------|
  3984. |    731 |
  4201. |    775 |
  4325. |    811 |
        +--------+

. * Cuba, Serbia, Angola, Iraq, Afghanistan, North Korea, Myanmar, Cambodia
. list ccode2 if ccode1==2 & USAtarget2==1 & year==2008

        +--------+
        | ccode2 |
        |--------|
    91. |     40 |
  4000. |    731 |
  4217. |    775 |
        +--------+

. * Cuba, North Korea, Myanmar
. 
. 
. keep if USSRsupport2==1
(490,241 observations deleted)

. gen intra_intens_bin=intra_intens

. replace intra_intens_bin=1 if intra_intens_bin==2
(17,467 real changes made)

. gen civwar=0

. replace civwar=1 if intra_intens==2
(17,467 real changes made)

. collapse (max) threat_bin intra_intens_bin civwar support_mi USAtarget2, by(ccode2 year)

. collapse (sum) threat_bin intra_intens_bin civwar USAtarget2 (mean) support_mi, by(year)

. 
. twoway (line civwar year, sort lcolor(lavender) lwidth(thick) lpattern(dash)) (line USAt
> arget2 year, sort lcolor(teal) lwidth(thick) lpattern(shortdash)) (bar support_mi year, 
> sort yaxis(2) fcolor(%40)), ytitle(# of USA threats/civil wars) yscale(range(0 10)) ytit
> le(Avg. Support Military Spending, axis(2)) legend(order(1 "Civil war" 2 "USA targets" 3
>  "Avg. Support Military Spending")) scheme(s1color)

. graph save Figures/sovietcollapse, replace
file Figures/sovietcollapse.gph saved

. graph export Figures/sovietcollapse.pdf, replace
file /Users/kcb38/Library/CloudStorage/Box-Box/Relation
    creation/JOPreplication/Figures/sovietcollapse.pdf saved as PDF format

. 
end of do-file

. log close
      name:  <unnamed>
       log:  /Users/kcb38/Library/CloudStorage/Box-Box/Relation creation/JOPreplication/Fi
> gA5_JOPreplication.log
  log type:  text
 closed on:  21 Aug 2023, 15:59:00
------------------------------------------------------------------------------------------
